package org.example.interceptor;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration// 声明配置类,代替xml文件
public class MyBatisPlusInterceptor {

    // 将mybatisPlus的拦截器注册为springBean
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {

        // 创建拦截器
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();

        // 添加分页拦截器
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor());

        return interceptor;
    }
}
